//
// Created by xili on 2024/8/28 18:45.
// GO BIG OR GO HOME.
//
#include "leetcode.h"

class Solution {
public:
    vector <string> buildArray(vector<int> &target, int n) {
        vector <string> ans;
        stack<int> s;
        int m = target.size();
        int j = 0;
        for (int i = 1; i <= n; i++) {
            if (j == m) {
                break;
            }
            s.push(i);
            ans.push_back("Push");
            if (s.top() != target[j]) {
                s.pop();
                ans.push_back("Pop");
            } else {
                j++;
            }
        }
        return ans;
    }
};